package leetcodecompetition.D369;

/**
 * @Author: Siantar
 * @Date: 2023-10-29-10:34
 * @Description: 1.0
 */
public class T100111 {
    public int findKOr(int[] nums, int k) {
        int[] sum = new int[31];
        for (int num : nums) {
            for (int i = 0; i < 31; i++) {
                if ((num & (1 << i)) > 0) {
                    sum[i]++;
                }
            }
        }
        int res = 0;
        for (int i = 0; i < 31; i++) {
            if (sum[i] >= k) {
                res += (1 << i);
            }
        }
        return res;
    }
}
